$(function(){
	//加载页面时，默认选中第一个停车场
	changeCss($("#one"));
	
	
	 //控制按钮点击页面跳转事件
	$("#one").click(function(){
		changeCss($(this));
		$(".content iframe").attr({
			"src":"home.html",
			// "name":"test"
		});
	});
	
	
	$("#two").click(function(){
		changeCss($(this));
		$(".content iframe").attr({
			"src":"home.html",
			// "name":"test"
		});
	});
	
	
	$("#three").click(function(){
		changeCss($(this));
		$(".content iframe").attr({
			"src":"home.html",
			// "name":"test"
		});
	});
	
	
	$("#four").click(function(){
		changeCss($(this));
		$(".content iframe").attr({
			"src":"home.html",
			// "name":"test"
		});
	});
	
	
	$("#five").click(function(){
		changeCss($(this));
		$(".content iframe").attr({
			"src":"home.html",
			// "name":"test"
		});
	});
	
	
	$("#six").click(function(){
		changeCss($(this));
		$(".content iframe").attr({
			"src":"home.html",
			// "name":"test"
		});
	});
 });


//点击样式改变
//参数是当前jq选择的节点
function changeCss(obj){
	//把rgb对象改为十六进制颜色值
	var color =  rgb2hex(obj.css("background-color"));
	
	if(color !== "#ffffff"){
		
		obj.css({"background-color":"#ffffff","color":"black"});
	}else{
		//先全部设置为白色，字体黑色
		$("div.parking_lots").css({"background-color":"#ffffff","color":"black"});
		//再把当前元素设置为蓝色
		obj.css({"background-color":"#0099FF","color":"white"});
	}
}


//rgb对象改为十六进制颜色值
function rgb2hex(rgb) {
	rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
	function hex(x) {
	return ("0" + parseInt(x).toString(16)).slice(-2);
	}
	return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
}


